angular.module('login',[])
.config(['$routeProvider',function($routeProvider){
	$routeProvider
	.when('/login',{
		templateUrl:'html/login/login.html',
		css:'html/login/login.css'
	})
}])
.controller('loginCtrl',function($scope,$rootScope){
	//头部和底部显示隐藏
	$rootScope.sh = false;
	//登录
	$scope.login = function(){
		$scope.nn=document.getElementsByClassName("login-input")[0].value;
		localStorage.sb = $scope.nn;
		var nn2=document.getElementsByClassName("login-input2")[0].value;
	 		var ajax= new XMLHttpRequest();
	 		ajax.open('POST','http://www.yanhanbo.top/user/login.php');
			ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	 		ajax.send('username='+$scope.nn+'&password='+nn2);
	 		ajax.onreadystatechange = function(){
 				if(ajax.readyState==4 && ajax.status==200){
	 				var obj = JSON.parse(ajax.responseText);
	 				if(obj.code == 1){
//	 					alert(obj.msg);
	 					setTimeout(function(){
	 						window.location.href="http://127.0.0.1:8020/pcduantao/Taocz%20PC/src/index.html#/home";
							location.reload();
	 					});
						localStorage.sb = $scope.nn;
						$rootScope.name=localStorage.sb;
					}else{
						alert(obj.msg);
					}
				}	
 			}
 	}
	


	
})